package com.swjd.controller;

import com.swjd.dao.TUserLogDao;
import com.swjd.pojo.TUserLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 刘涛
 * @create 2021/10/12 18:06
 */
@Controller
public class TUserLogController {
    @Autowired
    private TUserLogDao tUserLogDao;

    @RequestMapping("/LogManagement")
    public String LogManagement(Model model) {
        List<TUserLog> tUserLogs = tUserLogDao.selectList(null);
        model.addAttribute("tUserLogs",tUserLogs);
        return "user_log_management";
    }
    @RequestMapping("/index")
    public String index() {
        return "user_newlog";
    }
    @RequestMapping("/NewLog")
    public String NewLog(String title,String columns,String content,String permissions,String comment){
        TUserLog tUserLog = new TUserLog();
        tUserLog.setUser(title);
        tUserLog.setTitle(title);
        tUserLog.setColumns(columns);
        tUserLog.setContent(content);
        tUserLog.setPermissions(permissions);
        tUserLog.setComment(comment);
        tUserLogDao.insert(tUserLog);
        return "redirect:/LogManagement";
    }
}
